<?php

namespace Home\Controller;
use Think\Controller;

class MysiteController extends Controller {

    public function say1(){
        //$Book=new \Home\Model\BookModel('Book');
        //$Book=D("Book");
        $Book=M("Book");
        //trace($Book->getDbFields());
        //$res=$Book->where("id=10")->order("id")->select();
        //$res=$Book->where("bookCount=%d and author='%s'",array(8,"wong"))->select();
        $Book->where('bookCount=8')->catch(true)->order("id")->limit(2,3)->select();
        $res=$Book->data();
        trace(json_encode($res));
        $this->show("hello world");
    }

    public function say2(){
        G("begin");

        $Book=M("Book");
        $data["name"]="think in java";
        $data["author"]="huangjian";
        $data["bookCount"]=10;
        $data["price"]=20;
        $Book->data($data)->add();
        G("end");
        echo $Book->getLastSql();
        $time=G('begin','end').'s';
        trace($time);
    }


    public function index()
    {

        $arr["title"]="welcome";
        $arr["page"]="my page";

        $this->assign('arr',$arr);
        $this->display("index");
    }

    public function _empty($name){
        $this->city($name);
    }

    public function city($name){
        echo '当前城市:' . $name;
    }

    public function read(){
        if(I("get.id")){
            $this->res=I("get.id");
            trace($this->res);
        }else if(I('get.name')){
            $this->res=I("get.name");
            trace($this->res);
        }
        $this->show("welcome");
    }

    public function archive(){
        $year=$_GET["year"];
        $month=$_GET["month"];
        trace($year.$month);
    }

    public function aaa(){
        $data["code"]="0000000";
        $data['status']  = 1;
        $data['content'] = 'content';
        $this->ajaxReturn($data);
    }
}